# _*_ coding: utf-8 _*_
# @Time : 2024-01-19 23:21
# @Author : wf

# 安装 pip install selenium

# 驱动下载
# http://chromedriver.storage.googleapis.com/index.html

# 比较新的驱动
# https://googlechromelabs.github.io/chrome-for-testing/
#
# edge driver下载
# https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/?form=MA13LH

# 安装不同版本的chrome
# https://www.jianshu.com/p/69dd44b311e5


# 需要匹配相应的版本
# 打开闪退的解决方法
# https://blog.csdn.net/weixin_37259268/article/details/132151924

from selenium import webdriver

from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service

options = webdriver.EdgeOptions()
options.add_experimental_option('detach', True)
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_argument('--start-maximized')  # 设置窗口最大化
# options.binary_location = r'D:\Develop\Chrome\chrome104\Chrome-bin\chrome.exe'
# path = R'C:\Program Files\Google\Chrome\Application\chromedriver.exe'
# s = Service(path)

# Chrome 也可以打开
# browser = webdriver.Chrome(options=options)
browser = webdriver.Edge(options=options)

url = 'https://www.baidu.com'
browser.get(url)

browser.find_element(By.ID, 'kw').send_keys('我的世界\n')
